package cn.tedu.store.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.tedu.store.bean.Area;
import cn.tedu.store.bean.City;
import cn.tedu.store.bean.Province;
import cn.tedu.store.bean.ResponseResult;
import cn.tedu.store.service.IDictService;

@Controller
@RequestMapping("/dict")
public class DictController {
	@Resource
	private IDictService dictService;
	
	@RequestMapping("/showProvince.do")
	@ResponseBody
	public ResponseResult<List<Province>> showProvince(){
		ResponseResult<List<Province>> rr;
//		try {
			List<Province> listp=dictService.getProvinces();
			rr=new ResponseResult<List<Province>>();
			rr.setState(1);
			rr.setMessage("获取数据成功1");
			rr.setData(listp);
//		} catch (Exception e) {
//			rr=new ResponseResult<List<Province>>(0,"失败");
//		}
		return rr;
	}
	@RequestMapping("/showCity.do")
	@ResponseBody
	public ResponseResult<List<City>> showCity(String provinceCode){
		ResponseResult<List<City>> rr;
		List<City> listc=dictService.getCities(provinceCode);
		rr=new ResponseResult<List<City>>();
		rr.setState(1);
		rr.setMessage("获取数据成功2");
		rr.setData(listc);
		return rr;
	}
	@RequestMapping("/showArea.do")
	@ResponseBody
	public ResponseResult<List<Area>> showArea(String cityCode){
		ResponseResult<List<Area>> rr;
		List<Area> lista=dictService.getAreas(cityCode);
		rr=new ResponseResult<List<Area>>();
		rr.setState(1);
		rr.setMessage("获取数据成功3");
		rr.setData(lista);
		return rr;
	}
}
